﻿@{
    // these need to be in the head because MediaBrowser.js defines a callback that the thumbnail images call when they load,
    // which could happen as soon as they render.
    Style.Require("jQueryUI_Orchard").AtHead();
    Script.Require("JQuery").AtHead();
    Script.Require("jQueryUI_Tabs").AtHead();
    Script.Include("~/Modules/Orchard.MediaPicker/Scripts/MediaPicker.js");

    SetMeta("X-UA-Compatible", "IE=edge,chrome=1");
    Style.Include("~/themes/theadmin/styles/site.css");
    Style.Include("~/themes/theadmin/styles/ie.css").UseCondition("lte IE 8").SetAttribute("media", "screen, projection");
    Style.Include("~/themes/theadmin/styles/ie6.css").UseCondition("lte IE 6").SetAttribute("media", "screen, projection");

    Style.Include("ContentCreator.css");    
}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>@T("Select/create Content Item")</title>
    @Display.Metas()
    @Display.HeadScripts()
    @Display.HeadLinks()
    @Display.StyleSheetLinks()
</head>
<body id="orchard-content-creator">

    <script type="text/javascript">
        $.extend({
            contentCreator: {}
        });

        $.contentCreator.cannotPerformMsg = "@T("Cannot perform requested operation")";
        $.contentCreator.accessDeniedMsg = "@T("Authentication timed-out: please log-on again")";
        $.contentCreator.logonUrl = "@Url.Action("LogOn", new { Controller = "Account", Area = "Orchard.Users" })";
    </script>

    @Display.ContentCreatorNavigation()

    <div class="content-creator-tab">
        @Display(Model.Tab)
    </div>
    @using (Script.Foot())
    {
        <script type="text/javascript">
            //<![CDATA[
            $("ul a").each(function () {
                var self = $(this);
                var link = self.attr("href");
                var url = link.split("?");

                // if the link doesn't define the "callback" query string, then append it
                // n.b., pagers already append it
                if (url.length == 1 || query("callback", "?" + url[1]).length == 0) {
                    link = link + "?callback=" + query("callback");
                    self.attr("href", link);
                }

                url = link.split("?");

                // if the link doesn't define the "contentType" query string, then append it
                // n.b., pagers already append it
                if (url.length == 1 || query("contentType", "?" + url[1]).length == 0) {
                    link = link + "&contentType=" + query("contentType");
                    self.attr("href", link);
                }
            });

            // get a querystring value
            function query(name, querystring) {
                name = name.toLowerCase();
                var search = querystring || location.search;
                var parts = search.replace("?", "").replace("#", "").split("&");
                for (var i = 0, l = parts.length; i < l; i++) {
                    var part = parts[i];
                    var eqIndex = part.indexOf("=");
                    if (eqIndex !== -1 && part.substr(0, eqIndex).toLowerCase() === name) {
                        return part.substr(eqIndex + 1);
                    }
                }
                return [];
            }
            //]]>
        </script>
    }

    @Display.FootScripts()
</body>
</html>
